Skip to content

feat(pkg): solve all requested platforms together - #15982

Merged
Alizter merged 1 commit into
ocaml:mainfrom
Alizter:push-kzszzntwnrxt
Aug 26, 2026
Merged

feat(pkg): solve all requested platforms together#15982
Alizter merged 1 commit into
ocaml:mainfrom
Alizter:push-kzszzntwnrxt

Conversation

@Alizter

@Alizter Alizter commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Build one SAT universe containing every requested platform instead of solving each platform independently.
  • Make roles, availability, conflict classes, and result extraction platform-aware.
  • Constrain every platform role for a package to select the same version, choosing an older common version when necessary and failing when no common version exists.
  • Resolve each platform's package formulas against only the packages selected on that platform, preserving platform-specific dependency alternatives.
  • Generate conditional lock-file data directly from the joint result and remove obsolete result-merging APIs.
  • Keep diagnostics origin-aware: repository pre-rejections are reported only for repository-backed roles, and failures affecting a subset of requested platforms retain their platform qualifiers.
  • Remove the unreachable warning path for non-boolean availability filters, which are treated as unavailable.
  • Credit: the cross-platform version-equality SAT encoding was proposed by @art-w in portable lock directories should pick the same version for cross-platform packages #13647.

This branch is rebased on main after #16210 landed. It does not include #16172 or #16173.

Landed preparation

The following independent preparatory PRs have landed on main.

Observability and solver invariants

Per-platform semantics

Joint-solve edge cases

Build and tool integration

Independent related fixes

The following sibling PRs are based directly on main and are not dependencies of this PR:

Review fixes

  • Compute post-solve reachability separately for every platform before taking the union, so a local package's macOS alternative is not dropped after its Linux alternative is visited first.
  • Keep versions rejected on every platform out of manifest loading, while retaining platform-local candidates needed by another platform.
  • Do not attach repository pre-rejections to local or pinned roles, whose repository versions are not candidates.
  • Preserve platform annotations whenever a failure affects fewer than all requested platforms, including identical failures on two of four platforms.
  • Report cross-platform version conflicts with the selected version and platform instead of an opaque SAT clause.
  • Rename and rewrite the no-common-version regression so its name and prose match the enforced invariant.
  • Remove the redundant platform-version extra-files regression at the commit where joint version equality makes it obsolete.
  • Avoid constructing a discarded non-portable platform input and remove the unreachable non-boolean availability warning.

Checks

  • dune runtest test/blackbox-tests/test-cases/pkg/portable-lockdirs
  • CI=true dune build @fmt @check

Closes #13647

@Alizter Alizter added the package management Dune's package management — `(pkg)` stanza, lockdirs, `dune pkg` commands label Aug 17, 2026
@Alizter
Alizter force-pushed the push-kzszzntwnrxt branch 3 times, most recently from 6783d45 to bd35eab Compare August 17, 2026 11:39
@Alizter
Alizter force-pushed the push-kzszzntwnrxt branch from bd35eab to 33fe18e Compare August 17, 2026 11:50
@Alizter
Alizter marked this pull request as ready for review August 17, 2026 11:53
@Alizter
Alizter force-pushed the push-kzszzntwnrxt branch from 33fe18e to fa8b474 Compare August 17, 2026 14:08
@Alizter
Alizter force-pushed the push-kzszzntwnrxt branch from fa8b474 to ff35b1a Compare August 17, 2026 16:32
Alizter added a commit that referenced this pull request Aug 17, 2026
## Summary

- Add a trace-based regression for a lock directory with exactly one
requested platform.
- Assert the exact SAT problem size for a fixed one-package input: two
variables and two clauses.
- Guard against adding cross-platform consistency encoding to the
single-platform path.

This is an independent test-only performance baseline for the
joint-solver work in #15982.

## Tests

- `nix develop -c dune runtest
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-single-platform-sat-size.t`
- `CI=true nix develop -c dune build @fmt @check`
Alizter added a commit that referenced this pull request Aug 17, 2026
## Summary

- Add a portable lock-directory regression with distinct extra files
attached to two versions of one package.
- Constrain the solve to the common selected version and assert that its
file is copied into the lock directory.
- Assert that files belonging only to the rejected version are omitted.

This is an independent test-only baseline for per-platform lock
extraction in #15982.

## Tests

- `nix develop -c dune runtest
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-common-version-extra-files.t`
- `CI=true nix develop -c dune build @fmt @check`
Alizter added a commit that referenced this pull request Aug 17, 2026
## Summary

- Add a portable lock-directory regression for an unfiltered dependency
alternative whose implementations are available on different platforms.
- Assert that locking preserves the implementation selected for each
platform.
- Build the resulting lock directory on Linux and macOS to cover
consumption as well as the lock summary.

This snapshots the existing per-platform selection invariant before the
joint-solver change in #15982.

## Tests

- `nix develop -c dune runtest
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-platform-alternative-selection.t`
- `CI=true nix develop -c dune build @fmt @check`
@Alizter
Alizter force-pushed the push-kzszzntwnrxt branch from ff35b1a to bd76ef4 Compare August 17, 2026 18:07
@Alizter
Alizter marked this pull request as draft August 17, 2026 18:12
@Alizter
Alizter force-pushed the push-kzszzntwnrxt branch from bd76ef4 to d9132ec Compare August 17, 2026 18:44
Alizter added a commit that referenced this pull request Aug 17, 2026
## Summary

- Add a regression documenting that existing language versions currently
allow a portable lock directory to choose different versions of one
package on different platforms.
- Use mutually exclusive Linux and macOS availability filters to make
that behavior explicit.
- Establish the compatibility baseline changed by the joint solver.

This test intentionally documents legacy behavior; #15982 updates its
expectation to the intended all-platform failure when no common version
exists.

## Tests

- `nix develop -c dune runtest
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-language-version-compatibility.t`
- `CI=true nix develop -c dune build @fmt @check`
Alizter added a commit that referenced this pull request Aug 17, 2026
## Summary

- Add a portable lock-directory regression for a local package whose
dependency and conflict formulas contain platform filters.
- Request Linux explicitly and assert that `foo.2` remains selectable
there.
- Guard against evaluating local-package formulas in a platform-less
environment before multi-platform solving.

This is an independent test-only baseline for the joint-solver work in
#15982.

## Tests

- `nix develop -c dune runtest
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-local-platform-constraints.t`
- `CI=true nix develop -c dune build @fmt @check`
Alizter added a commit that referenced this pull request Aug 17, 2026
## Summary

- Add a portable lock-directory regression for a package that exists in
the repository but is unavailable on Linux.
- Assert that the solver reports `Availability condition not satisfied`
for the requested Linux platform.
- Guard against reconstructing rejection reasons in a platform-less
environment.

This is an independent test-only baseline for the joint-solver work in
#15982.

## Tests

- `nix develop -c dune runtest
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-platform-rejection-reason.t`
- `CI=true nix develop -c dune build @fmt @check`
@Alizter
Alizter force-pushed the push-kzszzntwnrxt branch 4 times, most recently from 5a6beb1 to 4530788 Compare August 18, 2026 10:54
@Alizter
Alizter force-pushed the push-kzszzntwnrxt branch 16 times, most recently from 77ab0c7 to 6382754 Compare August 25, 2026 11:51
@Alizter
Alizter force-pushed the push-kzszzntwnrxt branch 4 times, most recently from 68a22c6 to 52aee1a Compare August 25, 2026 23:44
@Alizter
Alizter force-pushed the push-kzszzntwnrxt branch from 52aee1a to 6301bf2 Compare August 25, 2026 23:54
Alizter added a commit that referenced this pull request Aug 26, 2026
## Summary

- Record the current per-platform diagnostic behavior before joint
multi-platform solving changes it.
- Cover a conditional dependency failing on one requested platform and
identical failures on two of four requested platforms.
- Cover a pin whose availability differs by platform, including
alternative selection and the mandatory-pin failure path without
reporting repository versions shadowed by the pin.
- Correct stale prose for non-boolean availability filters, which are
already treated as unavailable without printing a warning.

This is a green preparatory change for #15982; it does not change solver
behavior.

## Checks

- `dune runtest
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-all-or-nothing.t
test/blackbox-tests/test-cases/pkg/portable-lockdirs/portable-lockdirs-platform-rejection-reason.t
test/blackbox-tests/test-cases/pkg/unavailable-packages.t`
Build one SAT universe for every requested platform instead of solving
each platform independently. Enforce one version per package name across
platforms while allowing different package-name alternatives, evaluate
repository and pinned-package availability in each platform environment,
and minimize distinct avoid-version package versions. Preserve the existing
origin-specific rules: local packages bypass availability and local-package
refutation, while pinned packages bypass only local-package refutation.

Keep the single-platform SAT encoding unchanged, preserve each selected
platform package when extracting lock data, and only copy extra files for
selected package versions. Consolidate joint-solve diagnostics by package
while qualifying failures that affect only a subset of requested platforms.
Remove the unreachable warning for non-boolean availability filters, which
are treated as unavailable. Expose the final helper for deriving the base
solver environment and platform overlays for portable and non-portable
solves.

Signed-off-by: Ali Caglayan <alizter@gmail.com>
@Alizter
Alizter force-pushed the push-kzszzntwnrxt branch from 6301bf2 to 24cef7f Compare August 26, 2026 00:10
@Alizter
Alizter merged commit 020b334 into ocaml:main Aug 26, 2026
37 checks passed
@Alizter
Alizter deleted the push-kzszzntwnrxt branch August 26, 2026 06:36
@Alizter Alizter added this to the 3.25.0 milestone Aug 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package management Dune's package management — `(pkg)` stanza, lockdirs, `dune pkg` commands

Projects

None yet

Development

Successfully merging this pull request may close these issues.

portable lock directories should pick the same version for cross-platform packages

1 participant